import {
  ILoginResult,
  IUserInfoResult,
  IUserMenusResult
} from '@/store/login/types'
import requestUtils from '../index'
import { IDataType } from '../type'
import { AccountLoginType } from './type'

enum LoginAPI {
  AccountLogin = '/login',
  LoginUserInfo = '/users/',
  UserMenus = 'role/'
}

//登陆
export function AccountLoginRequest(account: AccountLoginType) {
  return requestUtils.post<IDataType<ILoginResult>>({
    url: LoginAPI.AccountLogin,
    data: account
  })
}

//用户信息
export function requestUserInfoById(id: number) {
  return requestUtils.get<IDataType<IUserInfoResult>>({
    url: LoginAPI.LoginUserInfo + id
  })
}

//用户菜单
export function requestUserMenusById(roleId: number) {
  return requestUtils.get<IDataType<IUserMenusResult>>({
    url: LoginAPI.UserMenus + roleId + '/menu'
  })
}
